/**
 * 防止刷新: 加载登录用户信息
 */
import Cookie from 'js-cookie'
import VueRouter from 'vue-router'

export const load = (store: any, router: VueRouter, $vue: any) => {
  console.info('router')
  console.info(router)
  // Cookie.get('t-user') as string: 断言,假设条件成立通过语法编译
  const user: object = Cookie.get('t-user') ? JSON.parse(Cookie.get('t-user') as string) : null
  if (user) {
    store.commit('login/setUser', user)
  } else {
    // $vue.$router.push({ name: 'login' })
    console.info($vue)
  }
}
